|
|
|
|
|
|
|
Then add the code in Listing 10.3 to allow each button to perform the specified action. |
|
|
|
|
|
|
|
|
LISTING 10.3. DAOEX3.TXTADDING NAVIGATION COMMAND BUTTONS TO THE FORM. |
|
|
|
 |
|
|
|
|
1: Private Sub cmdFirst_Click()
2: MyDyn.MoveFirst
3: Call DisplayFields
4: End Sub
5:
6: Private Sub cmdLast_Click()
7: MyDyn.MoveLast
8: Call DisplayFields
9: End Sub
10:
11: Private Sub cmdNext_Click()
12: MyDyn.MoveNext
13: Call DisplayFields
14: End Sub
15:
16: Private Sub cmdPrevious_Click()
17: MyDyn.MovePrevious
18: Call DisplayFields
19: End Sub |
|
|
|
|
|
|
|
|
Now execute the application and try using the command buttons that you just added. You should be able to move around the records in the query. You'll still have to deal with one problem, however, when you try to move past the beginning or end of the recordset. You should get an error message as shown in Figure 10.10. |
|
|
|
|
|
|
|
|
Figure 10.10.
Trying to move past the beginning
or end of a record will result in
an error. |
|
|
|
|
|
|
|
|
To prevent this from happening, you need to check the EOF and BOF properties of the recordset when moving forward or backward in the recordset. Listing 10.4 shows the additional code you need for this function. |
|
|
|
|
|